function f = contraction(theta2,sj,v,x2,p,QI,ind_market,deltaold) 



deltaoldold=deltaold;
expmu1 = expmu(theta2,v,x2,p);
toler=1e-12;
delta=zeros(length(sj),1);
logs_j=log(sj);
iter = 0; max_iter = 1e5;
xchng=1;

while ((iter < max_iter)  && (xchng > toler)  )
    iter=iter+1;
    delta=deltaoldold+logs_j-log(mktshares(deltaoldold,expmu1,QI,ind_market));
    xchng= max(abs(delta-deltaoldold));
    deltaoldold=delta;
end

if max(abs(sj-mktshares(delta,expmu1,QI,ind_market)))>toler  % double check that converged
    problem=1;
end

f=delta;